package kit.main;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;

import kit.core.ToZeroEntropyCalculator;
import kit.persistency.KitDB;
import kit.views.KitFrame;

public class Main {

	public static void main(String[] args) throws IOException {
		/* DEBUG *
		File f = new File(KitDB.DBName);
		if (f.exists())
			f.delete();
		/* DEBUG */

		KitDB db = null;
		File fileDB = new File(KitDB.DBName);
		if (!fileDB.exists()) {
			fileDB.createNewFile();
			db = new KitDB(fileDB.getAbsolutePath());
			try {
				db.dbDDL();
				if(!db.insertDomainElement()){
					System.err.println("Errore nell'inizializzazione del database.");
					fileDB.delete();
					System.exit(1);
				}
			} catch (SQLException e) {
				fileDB.delete();
				System.exit(1);
			}
		}else{
			db = new KitDB(fileDB.getAbsolutePath());
		}		
		KitFrame kit = new KitFrame();
		kit.setVisible(true);
	}

}
